﻿using Terraria;
using Terraria.ModLoader;

namespace PhantomRealm.Common.Systems
{
    public class TimeSystem : ModSystem
    {
        public delegate void TimeDelegate(bool day);
        public static event TimeDelegate TimeChanged;
        private bool _wasDayTime;
        public override void OnWorldLoad() => _wasDayTime = Main.dayTime;
        public override void PostUpdateEverything()
        {
            if (Main.dayTime != _wasDayTime)
            {
                TimeChanged?.Invoke(Main.dayTime);
            }
            _wasDayTime = Main.dayTime;
        }
        public override void Unload() => TimeChanged = null;
    }
}